home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / CONTRIB / ZLIB_PC.ZIP / zlib_pc / zdef.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-20  |  3.9 KB  |  122 lines

  1. #undef DEBUG    /*1*/
  2. #undef MONITOR_CRLF
  3.  
  4. /*
  5.  *    zdef.h
  6.  */
  7.  
  8. /*
  9.  *    These wondrous debugging macros helped me find the nasty bug which
  10.  *    only manifested itself on msdos -- stackp has to be a long on msdos
  11.  *    because the array it is indexing is 'huge' ...
  12.  */
  13. #ifdef DEBUG
  14. int    debug = 1;
  15. # define TRACT(lev, stmnt)    if (lev <= debug) fprintf(stderr, "%d: %s\n", __LINE__, #stmnt);
  16. # define TRACE(lev, stmnt)    if (lev <= debug) fprintf(stderr, "%d: %s\n", __LINE__, #stmnt); stmnt
  17. # define TRACA(lev, stmnt)    stmnt; if (lev <= debug) fprintf(stderr, "%d: %s\n", __LINE__, #stmnt);
  18. # define TRACL(lev, var)    if (lev <= debug) fprintf(stderr, "%d: %s <- %ld\n", __LINE__, #var, var);
  19. #else
  20. # define TRACT(lev, stmnt)
  21. # define TRACE(lev, stmnt) stmnt
  22. # define TRACA(lev, stmnt) stmnt
  23. # define TRACL(lev, var)
  24. #endif
  25.  
  26.  
  27. /* 
  28.  *
  29.  * Originally:
  30.  *
  31.  * compress.c - File compression ala IEEE Computer, June 1984.
  32.  *
  33.  * Authors:    Spencer W. Thomas       (decvax!harpo!utah-cs!utah-gr!thomas)
  34.  *             Jim McKie               (decvax!mcvax!jim)
  35.  *             Steve Davies            (decvax!vax135!petsd!peora!srd)
  36.  *             Ken Turkowski           (decvax!decwrl!turtlevax!ken)
  37.  *             James A. Woods          (decvax!ihnp4!ames!jaw)
  38.  *             Joe Orost               (decvax!vax135!petsd!joe)
  39.  *
  40.  * $Header: zlib.c,v 4.1 90/11/12 14:52:24 gtoal Release $
  41.  *
  42.  * Graham Toal, 3rd September 1988.  My changes released to public domain.
  43.  *                                   Updated Nov 90.
  44.  *
  45.  * The original decompress has been restructured so that data can be
  46.  * fetched on demand a byte at a time.  This lets it be used as a filter
  47.  * for programs which read large data files - you do not need the disk
  48.  * space to decompress the input files first.
  49.  *
  50.  * (Incidentally, programs reading data off floppies will be speeded up
  51.  *  because decompression is always faster than the equivalent amount
  52.  *  of disk I/O).
  53.  *
  54.  * This implementation supplies 'z' versions of fopen, fputc, feof and fclose
  55.  * to be used as direct substitutes for the originals; it would be cleaner
  56.  * and more transparent if the decompress filter were hidden under the
  57.  * real stdio procedures.  An extra call zfilter() is supplied to convert
  58.  * an already-opened stream into a z-stream: see the example at the end
  59.  * of this file.
  60.  *
  61.  * If a file opened by zfopen() was not compressed, the files contents are
  62.  * still recovered correctly at the low expense of an extra procedure call
  63.  * per byte.  This makes the routines more generally usable - they can be
  64.  * left in production programs which can be speeded up in the field by
  65.  * compressing selected input files(*); also, files can be compressed or
  66.  * not selectively depending on whether the compression makes them
  67.  * smaller or not - code accessing the files does not need to know.
  68.  *
  69.  * [(*) reading from a compressed file off floppy disk is faster than
  70.  * reading from an uncompressed file. This probably isn't true of
  71.  * hard disks though.]
  72.  *
  73.  * BUGS: Opening a file "r" will not do CR/LF processing on computers with
  74.  *       this file structure.
  75.  */
  76.  
  77.  
  78. #if defined(__unix) && !defined(unix)
  79. #define unix 1
  80. #endif
  81.  
  82. #include <stdio.h>
  83. #include <string.h>
  84. #ifdef __STDC__
  85. # include <stdlib.h>
  86. #else
  87. # define size_t        int
  88. #endif
  89. #include <ctype.h>
  90.  
  91. #if defined(MSDOS)
  92. # include <malloc.h>
  93. #elif ! defined(unix) && ! defined(__unix)
  94. extern char    *malloc ();
  95. #endif
  96.  
  97. #ifndef min
  98. # define min(a,b)    ((a>b) ? b : a)
  99. # endif
  100. #define HSIZE        69001L        /* 95% occupancy */
  101.  
  102. /*
  103.  *    the next two codes should not be changed lightly, as they must not
  104.  *    lie within the contiguous general code space.
  105.  */
  106. #define FIRST        257L        /* first free entry */
  107. #define CLEAR        256L        /* table clear output code */
  108.  
  109. #define BIT_MASK        0x1f
  110. #define BLOCK_MASK      0x80
  111. #define INIT_BITS       9        /* initial number of bits/code */
  112.  
  113. #define CHECK_GAP    10000L        /* ratio check interval */
  114.  
  115. #include "zlib.h"
  116.  
  117. #define NOT_COMPRESSED    1
  118. #define ALLOCATED    2
  119.  
  120.  
  121. /* end of zdef.h */
  122.